package com.hotel.tv.web.admin.controllers;

import com.autumn.mybatis.mapper.PageResult;
import com.autumn.web.controllers.AbstractEditController;
import com.autumn.zero.file.storage.FileStorageUtils;
import com.autumn.zero.file.storage.services.vo.FileAttachmentInformationResponse;
import com.hotel.tv.application.admin.dto.emp.*;
import com.hotel.tv.application.admin.services.emp.EmpInfoAppService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresUser;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.Valid;

/**
 * <p>
 * </p>
 *
 * @description TODO
 * @author: 老码农
 * @create: 2020-04-08 15:36
 **/
@RestController
@RequestMapping("/emp")
@Api(tags = "员工管理")
@RequiresUser
public class EmpInfoController extends AbstractEditController<EmpInfoInput, EmpInfoInput, EmpInfoListOutput, EmpInfoDetailsOutput, EmpInfoAppService> {

    /**
     * 实例化
     *
     * @param service 服务
     */
    public EmpInfoController(EmpInfoAppService service) {
        super(service);
    }

    /**
     * 上传附件
     *
     * @param file
     * @return
     * @throws Exception
     */
    @PostMapping("/upload/file")
    @ApiOperation(value = "上传附件")
    public FileAttachmentInformationResponse uploadFile(@RequestParam("file") MultipartFile file)
            throws Exception {
        return FileStorageUtils.saveUploadFile(this.service, file);
    }

    /**
     * 分页查询1
     *
     * @param input
     * @return
     */
    @PostMapping("/query/page/cus")
    @ApiOperation(value = "分页查询1")
    public PageResult<EmpInfoListOutput> queryForCusPage(@Valid @RequestBody EmpAdvancedPageQueryInput input) {
        return super.queryForPage(input);
    }

    /**
     *
     * @param input
     * @return
     */
    @PostMapping("/query/page/cus/2")
    @ApiOperation(value = "分页查询2")
    public PageResult<EmpInfoListOutput> queryForCusPage(@Valid @RequestBody EmpCusAdvancedPageQueryInput input) {
        return this.service.queryForCusPage(input);
    }
}
